package com.example.spzx.Service.impl;

import cn.hutool.db.PageResult;
import com.example.spzx.Mapper.SysRoleMapper;
import com.example.spzx.Service.SysRoleService;
import com.example.spzx.model.dto.system.SysRoleDto;
import com.example.spzx.model.entity.system.SysRole;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import jakarta.annotation.Resource;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class SysRoleServiceImpl implements SysRoleService {
    @Resource
    private SysRoleMapper sysRoleMapper;

    public PageInfo<SysRole> selectlist(String roleName, Integer pageNum, Integer pageSize) {
        PageHelper.startPage(pageNum, pageSize);
        Page<SysRole> list = sysRoleMapper.selectlist(roleName);

        PageInfo<SysRole> pageResult = new PageInfo<>();
        pageResult.setTotal((int) list.getTotal());
        pageResult.setList(list.getResult());
        return pageResult;
    }
    public   void add(SysRole sysRole){
        sysRoleMapper.add(sysRole);
    }
    public  void update(SysRole sysRole){
        sysRoleMapper.update(sysRole);
    }
    public    void delete(Integer id){
        sysRoleMapper.delete(id);
    }
    public List<SysRole> selectall(){
        List<SysRole> list=sysRoleMapper.selectall();
        return list;
    }
}
